"""
@author: wtf
@file: util.py
@time: 2024/5/30 16:38
@desc: 工具类
"""
import os

from qiniu import put_file, put_data, BucketManager

import config
from exts import q


def send_photos(photos, save_name):
    # 上传空间名称
    bucket_name = 'wtfwt9876'
    # 生成上传 Token，可以指定过期时间等
    token = q.upload_token(bucket_name, save_name, 3600)
    print(save_name)
    print(token)
    ret, info = put_data(token, save_name, photos)
    print(info)
    return ret, info, token


def qiniu_delete_photos(save_name):
    # 上传空间名称
    bucket_name = 'wtfwt9876'
    # 初始化BucketManager
    bucket = BucketManager(q)
    ret, info = bucket.delete(bucket_name, save_name)
    return ret, info
